package com.example.myapplication.progress;

import android.os.Handler;
import android.widget.ProgressBar;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.example.myapplication.R;

public class ProgressActivity extends AppCompatActivity {

    private Handler handle = new Handler();

    private ProgressBar progressBar;
    volatile int progressNumber = 0;

    private Runnable runnable = new Runnable() {
        @Override
        public void run() {
            progressNumber++;

            if (progressNumber == 100) {
                handle.removeCallbacks(this);
            }
            progressBar.setProgress(progressNumber);
            handle.postDelayed(runnable, 100);
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_progress);
        progressBar = findViewById(R.id.progress_1);
        handle.postDelayed(runnable, 100);
    }
}
